//
//  YXComUtil.h
//  SeniorCarRepairing
//
//  Created by xmdfst on 16/9/29.
//  Copyright © 2016年 xmdfst. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>

#pragma mark - COLOR Util
#define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f \
blue:(b)/255.0f alpha:1.0f]
//#define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f \
//alpha:(a)]
#define RGBA(r,g,b,a) (r)/255.0f, (g)/255.0f, (b)/255.0f, (a)

//#define UIColorFromRGB(rgbValue) [UIColor \
//colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
//green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
//blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]


#pragma mark - FONT Util
#define FONT(x)         [UIFont systemFontOfSize:x]
#define FONT_BOLD(x)    [UIFont boldSystemFontOfSize:x]

#define kAvatarImageSize    CGSizeMake(200,200)


@interface YXComUtil : NSObject

/**
 *  @author LYX, 16-09-29 17:09:40
 *
 *  按需要大小压缩图片
 *
 *  @param image 原始图片
 *  @param size  需要的size
 *
 *  @return 压缩后的图片
 *
 *  @since <#1.0#>
 */
+(UIImage*)originImage:(UIImage *)image scaleToSize:(CGSize)size;
/**
 *  @author LYX, 16-10-20 18:10:25
 *
 *  转化图片
 *
 *  @param image 图片
 *
 */
+ (NSData *)compressImage:(UIImage *)image;

#pragma mark - 系统路径相关
/**
 *  @author LYX, 16-09-29 17:09:16
 *
 *  App 临时文件路径
 *
 *  @return 路径
 *
 *  @since <#1.0#>
 */
+(NSString*)getTempFilePath;

/**
 *  @author LYX, 16-09-29 17:09:54
 *
 *  App Document 路径
 *
 *  @return 路径
 *
 *  @since <#1.0#>
 */
+(NSString*)getDocumentPath;
/**
 *  @author LYX, 16-09-29 17:09:53
 *
 *  App Library 路径
 *
 *  @return 路径 /Library/
 *
 *  @since <#1.0#>
 */
+(NSString*)getLibraryPath;

/**
 *  @author LYX, 16-09-29 17:09:03
 *
 *  App 缓存路劲
 *
 *  @return 缓存路径 /Library/Caches/
 *
 *  @since <#1.0#>
 */
+(NSString*)getCachePath;

/**
 *  @author LYX, 16-09-29 17:09:02
 *
 *  简单提示框
 *
 *  @param title   标题
 *  @param content 内容
 *
 *  @since <#1.0#>
 */
+(void)alertWithTitle:(NSString*)title content:(NSString*)content;

/**
 *  @author LYX, 16-09-29 17:09:28
 *
 *  简单提示框
 *
 *  @param content 提示内容
 *
 *  @since <#1.0#>
 */
+(void)alert:(NSString*)content;

/**
 *  @author LYX, 16-09-29 17:09:28
 *
 *  中文转拼音
 *
 *  @param src 中文
 *
 *  @return 拼音
 *
 *  @since <#1.0#>
 */
+(NSString*)toPinyin:(NSString*)src;

/**
 *  @author LYX, 16-09-29 17:09:52
 *
 *  摆正有旋转的图片进行
 *
 *  @param srcImg 原始图片
 *
 *  @return 摆正后的图片
 *
 *  @since <#1.0#>
 */
+(UIImage *)fixOrientation:(UIImage *)srcImg;

/**
 *  @author LYX, 16-09-29 17:09:12
 *
 *  摆正有旋转的图片
 *
 *  @param srcImg 原始图片
 *  @param ori    图片旋转方式
 *
 *  @return 摆正后的图片
 *
 *  @since <#1.0#>
 */
+(UIImage*)fixOrientation:(UIImage*)srcImg orientation:(UIImageOrientation)ori;


/**
 *  @author LYX, 16-09-29 17:09:37
 *
 *  浮点 是否含有小数位
 *
 *  @param num 数字
 *
 *  @return 有或没有
 *
 *  @since <#1.0#>
 */
+(BOOL)isFloatHasDecimal:(double)num;

/**
 *  @author LYX, 16-09-29 17:09:41
 *
 *  判断是不是今天
 *
 *  @since <#1.0#>
 */
+(BOOL)isToday:(long long)timeMinSec;
/**
 *  @author LYX, 16-09-29 17:09:20
 *
 *  两个是否是同一天
 *
 *  @since <#1.0#>
 */
+(BOOL)isSameDay:(NSDate*)date1 date2:(NSDate*)date2;
/**
 *  @author LYX, 16-09-29 17:09:27
 *
 *  某天经过offsetDay的日期
 *
 *  @param date      基准时间
 *  @param offsetDay 间隔时间
 *
 *  @return 最终时间
 *
 *  @since <#1.0#>
 */
+(NSDate*)date:(NSDate*)date withOffsetDay:(NSInteger)offsetDay;
/**
 *  @author LYX, 16-09-29 17:09:05
 *
 *  获取周几
 *
 *  @param date 日期
 *
 *  @return 周几
 *
 *  @since <#1.0#>
 */
+(NSInteger)getWeakDayOfDate:(NSDate*)date;
/**
 *  @author LYX, 16-09-29 17:09:51
 *
 *  将long 类型的时间按照dateformat要求转换成NSString类型
 *
 *  @param msSince1970 时间
 *  @param format      时间格式
 *
 *  @return 时间字符串
 *
 *  @since <#1.0#>
 */
+(NSString *)dateFromLongLong:(long long)msSince1970 dateFormat:(NSString *)format;
/**
 *  @author LYX, 16-09-29 17:09:41
 *
 *  创建唯一标识符
 *
 *  @return 唯一标识符
 *
 *  @since <#1.0#>
 */
+(NSString*)createUUID;
/**
 *  @author LYX, 16-09-29 17:09:44
 *
 *  获取相机权限
 *
 *  @return 权限状态
 *
 *  @since <#1.0#>
 */
+(AVAuthorizationStatus)cameraAuthorStatus;

/**
 *  @author LYX, 16-09-29 17:09:40
 *
 *  获取设备详细型号
 *
 *  @since <#1.0#>
 */
+ (NSString *)getCurrentDeviceModel;
// 获取应用版本编号
+ (NSString *)getCurrentBundleVersion;
// 获取应用版本
+ (NSString *)getCurrentBundleShortVersionString;
// 获取设备系统
+ (NSString *)getCurrentSystemVersion;
// 获取boundleId
+(NSString*)getBundleId;

/**
 *  @author LYX, 16-10-14 11:10:23
 *
 *  将字符串进行MD5加密
 *
 *  @param inputStr 要加密的字符串
 *
 *  @return 加密后的字符串
 */
+(NSString *)encryptStringWithMD5:(NSString *)inputStr;


/**
 将时间戳转成字符串格式

 @param time 时间戳
 @param formate 格式：如@“yyyyMMddHHmmss”
 @return 字符串的时间
 */
+(NSString *)changeTimeToTimeStr:(long long)time formate:(NSString*)formate;




#pragma mark - 获取样式价格
+(NSMutableAttributedString *)getAttributedStrOfPrice:(double)price;
+(NSMutableAttributedString *)getAttributedStrOfPrice:(double)price centerFontSize:(NSInteger)font;
#pragma mark- 获取时间:yyyy-MM-dd hh:mm:ss
+(NSString*)getTimeStr:(NSString*)time;

#pragma mark - alert
/**
 弹窗
 
 @param title 标题
 @param actionName 点击确定的方法名
 @param controller 控制器
 @param preferredStyle 弹窗显示格式
 */
+(void)createAlertWithTitle:(NSString*)title sureActionName:(NSString*)actionName viewController:(UIViewController*)controller preferredStyle:(UIAlertControllerStyle)preferredStyle;
+(void)createAlertWithTitle:(NSString*)title viewController:(UIViewController*)controller;

#pragma mark - image scale utility

/**
 将图片按屏幕大小的比例同等放大或者缩小成屏幕大小

 @param sourceImage 原图
 @return 改变后的图片
 */
+(UIImage *)imageByScalingToMaxSize:(UIImage *)sourceImage;

@end
